import 'package:vista/shared/models/base_frame.dart';

/// 用户画面
/// 存储用户信息，如摄影中的画面般记录用户特征
class UserFrame extends BaseFrame {
  final String id;
  final String account; // 账号，用于登录
  final String username; // 用户名
  final String password; // 实际项目中应该加密存储
  final String? avatar; // 头像URL
  final String? signature; // 个性签名

  const UserFrame({
    required this.id,
    required this.account,
    required this.username,
    required this.password,
    this.avatar,
    this.signature,
  });

  /// 从JSON创建用户画面
  factory UserFrame.fromJson(Map<String, dynamic> json) {
    return UserFrame(
      id: json['id'] as String,
      account: json['account'] as String,
      username: json['username'] as String,
      password: json['password'] as String,
      avatar: json['avatar'] as String?,
      signature: json['signature'] as String?,
    );
  }

  @override
  List<Object?> get props => [id, account, username, avatar, signature];

  @override
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'account': account,
      'username': username,
      'password': password,
      if (avatar != null) 'avatar': avatar,
      if (signature != null) 'signature': signature,
    };
  }
}
